package cn.echo.consul.manager.exception;

import cn.echo.consul.manager.response.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static cn.echo.consul.manager.response.ResultCode.F11400;

/**
 * 业务服务异常 不计入hystrix bad统计
 *
 * @author lonyee
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BizServiceException extends RuntimeException {

    private static final long serialVersionUID = -3558232926509169926L;

    private Integer code;
    private String msg;

    public BizServiceException(Integer code, String msg, Object... args) {
        super(String.format(msg, args));
        this.code = code;
        this.msg = String.format(msg, args);
    }

    public BizServiceException(ResultCode resultCode, Object... args) {
        this(resultCode.getCode(), resultCode.getMsg(), args);
    }


    public BizServiceException(String msg) {
        this(F11400.getCode(), msg);
    }

}
